package com.wcity.manage.dao.mapper;

import com.wcity.manage.dao.dal.BaseMapper;
import com.wcity.manage.dao.model.Verify;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
 * Created by jn on 2016/12/10.
 * 验证码dao
 */
@Repository
public interface VerifyMapper extends BaseMapper<Verify,Serializable> {

    /**
     * 查询code
     * @param phone
     * @param code
     * @param type
     * @return
     */
    @Select(" select * from td_verify where phone = #{phone} and code = #{code} and type = #{type} ")
    Verify find(@Param("phone")String phone,@Param("code")String code,@Param("type")int type);

    /**
     * 主键更新
     * @param id
     * @return
     */
    @Update(" update td_verify set status = 2 where id = #{id} ")
    int update(int id);

    /**
     * 更新状态
     * @param phone
     * @param type
     * @return
     */
    @Update(" update td_verify set status = 2 where phone = #{phone} and type = #{type} ")
    int updateCode(@Param("phone")String phone,@Param("type")int type);

}
